import { CoolController, BaseController } from '@cool-midway/core';
import { Body, Inject, Post, Get, Query } from '@midwayjs/core';
import { GameLevelRecordEntity } from '../../entity/record';
import { GameLevelRecordService } from '../../service/record';
import { GameLevelInfoEntity } from '../../entity/info';
import { UserInfoEntity } from '../../../user/entity/info';

/**
 * game模块-游戏记录
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: GameLevelRecordEntity,
  service: GameLevelRecordService,
  pageQueryOp: {
    keyWordLikeFields: ['remark'],
    fieldEq: ['type', 'mode', 'difficulty', 'a.status','playerId'],
    select: ['a.*', 'b.name as levelName','c.avatarUrl as ownerAvatar', 'c.nickName as ownerNickname', 'd.avatarUrl as memberAvatar', 'd.nickName as memberNickname'],
    join: [
      {
        entity: GameLevelInfoEntity,
        alias: 'b',
        condition: 'a.levelId = b.id',
        type: 'leftJoin',
      },
      {
        entity: UserInfoEntity,
        alias: 'c',
        condition: 'a.playerId = c.id',
        type: 'leftJoin',
      },
      {
        entity: UserInfoEntity,
        alias: 'd',
        condition: 'a.secondPlayerId = d.id',
        type: 'leftJoin',
      }
    ],
  }
})
export class AdminGameLevelRecordController extends BaseController {
  @Inject()
  gameLevelRecordService: GameLevelRecordService;
}
